home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 3.iso / dist / fw_qt3.idb / usr / freeware / Qt / extensions / xt / src / qxt.cpp.z / qxt.cpp
Encoding:
C/C++ Source or Header  |  2002-04-08  |  18.1 KB  |  645 lines

  1. /****************************************************************************
  2. ** $Id$
  3. **
  4. ** Implementation of Qt extension classes for Xt/Motif support.
  5. **
  6. ** Created : 980107
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38. #include <qapplication.h>
  39. #include <qwidget.h>
  40. #include <qobjectlist.h>
  41.  
  42. #include "qxt.h"
  43.  
  44. #include <stdio.h>
  45. #include <string.h>
  46. #include <time.h>
  47. #include <limits.h>
  48.  
  49. #include <X11/Xlib.h>
  50. #include <X11/Intrinsic.h>
  51. #include <X11/IntrinsicP.h> // for XtCreateWindow
  52. #include <X11/Shell.h>
  53. #include <X11/StringDefs.h>
  54. #include <X11/Xutil.h>
  55. #include <X11/Xos.h>
  56.  
  57. const int XKeyPress = KeyPress;
  58. const int XKeyRelease = KeyRelease;
  59. #undef KeyPress
  60. #undef KeyRelease
  61.  
  62. extern Atom qt_wm_state;
  63.  
  64. //#define HAVE_MOTIF
  65. #ifdef HAVE_MOTIF
  66. #include <Xm/Xm.h>
  67. #endif
  68.  
  69. typedef void (*SameAsXtTimerCallbackProc)(void*,void*);
  70. typedef void (*IntervalSetter)(int);
  71. typedef void (*ForeignEventProc)(XEvent*);
  72.  
  73. extern XtEventDispatchProc
  74.  qt_np_cascade_event_handler[LASTEvent];      // defined in qnpsupport.cpp
  75. void            qt_reset_color_avail();       // defined in qcolor_x11.cpp
  76. int             qt_activate_timers();         // defined in qapplication_x11.cpp
  77. timeval        *qt_wait_timer();              // defined in qapplication_x11.cpp
  78. void        qt_x11SendPostedEvents();     // defined in qapplication_x11.cpp
  79. int    qt_event_handler( XEvent* event );    // defined in qnpsupport.cpp
  80. extern int      qt_np_count;                  // defined in qnpsupport.cpp
  81. void qt_np_timeout( void* p, void* id );      // defined in qnpsupport.cpp
  82. void qt_np_add_timeoutcb(
  83.     SameAsXtTimerCallbackProc cb );       // defined in qnpsupport.cpp
  84. void qt_np_remove_timeoutcb(
  85.     SameAsXtTimerCallbackProc cb );       // defined in qnpsupport.cpp
  86. void qt_np_add_timer_setter(
  87.     IntervalSetter is );                  // defined in qnpsupport.cpp
  88. void qt_np_remove_timer_setter(
  89.     IntervalSetter is );                  // defined in qnpsupport.cpp
  90. extern XtIntervalId qt_np_timerid;            // defined in qnpsupport.cpp
  91. extern void (*qt_np_leave_cb)
  92.               (XLeaveWindowEvent*);           // defined in qnpsupport.cpp
  93. void qt_np_add_event_proc(
  94.         ForeignEventProc fep );           // defined in qnpsupport.cpp
  95. void qt_np_remove_event_proc(
  96.         ForeignEventProc fep );           // defined in qnpsupport.cpp
  97.  
  98.  
  99. typedef struct {
  100.     int empty;
  101. } QWidgetClassPart;
  102.  
  103. typedef struct _QWidgetClassRec {
  104.     CoreClassPart    core_class;
  105.     QWidgetClassPart    qwidget_class;
  106. } QWidgetClassRec;
  107.  
  108. //static QWidgetClassRec qwidgetClassRec;
  109.  
  110. typedef struct {
  111.     /* resources */
  112.     /* (none) */
  113.     /* private state */
  114.     QXtWidget* qxtwidget;
  115. } QWidgetPart;
  116.  
  117. typedef struct _QWidgetRec {
  118.     CorePart    core;
  119.     QWidgetPart    qwidget;
  120. } QWidgetRec;
  121.  
  122.  
  123. static
  124. void reparentChildrenOf(QWidget* parent)
  125. {
  126.  
  127.     if ( !parent->children() )
  128.     return; // nothing to do
  129.  
  130.     for ( QObjectListIt it( *parent->children() ); it.current(); ++it ) {
  131.     if ( it.current()->isWidgetType() ) {
  132.         QWidget* widget = (QWidget*)it.current();
  133.         XReparentWindow( qt_xdisplay(),
  134.                  widget->winId(),
  135.                  parent->winId(),
  136.                  widget->x(),
  137.                  widget->y() );
  138.         if ( widget->isVisible() )
  139.         XMapWindow( qt_xdisplay(), widget->winId() );
  140.     }
  141.     }
  142.  
  143. }
  144.  
  145. void qwidget_realize(
  146.     Widget                widget,
  147.     XtValueMask*          mask,
  148.     XSetWindowAttributes* attributes
  149.     )
  150. {
  151.     widgetClassRec.core_class.realize(widget, mask, attributes);
  152.     QXtWidget* qxtw = ((QWidgetRec*)widget)->qwidget.qxtwidget;
  153.     if (XtWindow(widget) != qxtw->winId()) {
  154.     qxtw->create(XtWindow(widget), FALSE, FALSE);
  155.     reparentChildrenOf(qxtw);
  156.     }
  157.     qxtw->show();
  158.     XMapWindow( qt_xdisplay(), qxtw->winId() );
  159. }
  160.  
  161. static
  162. QWidgetClassRec qwidgetClassRec = {
  163.   { /* core fields */
  164.     /* superclass        */    (WidgetClass) &widgetClassRec,
  165.     /* class_name        */    (char*)"QWidget",
  166.     /* widget_size        */    sizeof(QWidgetRec),
  167.     /* class_initialize        */    0,
  168.     /* class_part_initialize    */    0,
  169.     /* class_inited        */    FALSE,
  170.     /* initialize        */    0,
  171.     /* initialize_hook        */    0,
  172.     /* realize            */    qwidget_realize,
  173.     /* actions            */    0,
  174.     /* num_actions        */    0,
  175.     /* resources        */    0,
  176.     /* num_resources        */    0,
  177.     /* xrm_class        */    NULLQUARK,
  178.     /* compress_motion        */    TRUE,
  179.     /* compress_exposure    */    TRUE,
  180.     /* compress_enterleave    */    TRUE,
  181.     /* visible_interest        */    FALSE,
  182.     /* destroy            */    0,
  183.     /* resize            */    XtInheritResize,
  184.     /* expose            */    XtInheritExpose,
  185.     /* set_values        */    0,
  186.     /* set_values_hook        */    0,
  187.     /* set_values_almost    */    XtInheritSetValuesAlmost,
  188.     /* get_values_hook        */    0,
  189.     /* accept_focus        */    XtInheritAcceptFocus,
  190.     /* version            */    XtVersion,
  191.     /* callback_private        */    0,
  192.     /* tm_table            */    XtInheritTranslations,
  193.     /* query_geometry        */    XtInheritQueryGeometry,
  194.     /* display_accelerator    */    XtInheritDisplayAccelerator,
  195.     /* extension        */    0
  196.   },
  197.   { /* qwidget fields */
  198.     /* empty            */    0
  199.   }
  200. };
  201. static WidgetClass qWidgetClass = (WidgetClass)&qwidgetClassRec;
  202.  
  203. static bool filters_installed = FALSE;
  204. static QXtApplication* qxtapp = 0;
  205. static XtAppContext appcon;
  206.  
  207. static
  208. Boolean qt_event_handler_wrapper( XEvent* event )
  209. {
  210.     return (Boolean)qt_event_handler( event );
  211. }
  212.  
  213. static
  214. void installXtEventFilters()
  215. {
  216.     if (filters_installed) return;
  217.     // Get Xt out of our face - install filter on every event type
  218.     for (int et=2; et < LASTEvent; et++) {
  219.     qt_np_cascade_event_handler[et] = XtSetEventDispatcher(
  220.         qt_xdisplay(), et, qt_event_handler_wrapper );
  221.     }
  222.     filters_installed = TRUE;
  223. }
  224.  
  225. static
  226. void removeXtEventFilters()
  227. {
  228.     if (!filters_installed) return;
  229.     // We aren't needed any more... slink back into the shadows.
  230.     for (int et=2; et < LASTEvent; et++) {
  231.     XtSetEventDispatcher(
  232.         qt_xdisplay(), et, qt_np_cascade_event_handler[et] );
  233.     }
  234.     filters_installed = FALSE;
  235. }
  236.  
  237. // When we are in an event loop of QApplication rather than the browser's
  238. // event loop (eg. for a modal dialog), we still send events to Xt.
  239. static
  240. void np_event_proc( XEvent* e )
  241. {
  242.     Widget xtw = XtWindowToWidget( e->xany.display, e->xany.window );
  243.     if ( xtw && qApp->loopLevel() > 0 ) {
  244.     // Allow Xt to process the event
  245.     qt_np_cascade_event_handler[e->type]( e );
  246.     }
  247. }
  248.  
  249. static void np_set_timer( int interval )
  250. {
  251.     // Ensure we only have one timeout in progress - QApplication is
  252.     // computing the one amount of time we need to wait.
  253.     if ( qt_np_timerid ) {
  254.     XtRemoveTimeOut( qt_np_timerid );
  255.     }
  256.     qt_np_timerid = XtAppAddTimeOut(appcon, interval,
  257.     (XtTimerCallbackProc)qt_np_timeout, 0);
  258. }
  259.  
  260. static void np_do_timers( void*, void* )
  261. {
  262.     qt_np_timerid = 0; // It's us, and we just expired, that's why we are here.
  263.  
  264.     qt_activate_timers();
  265.  
  266.     timeval *tm = qt_wait_timer();
  267.  
  268.     if (tm) {
  269.     int interval = QMIN(tm->tv_sec,INT_MAX/1000)*1000 + tm->tv_usec/1000;
  270.     np_set_timer( interval );
  271.     }
  272.     qxtapp->sendPostedEvents();
  273. }
  274.  
  275. /*!
  276.   \class QXtApplication qxt.h
  277.   \brief The QXtApplication class facilitates the mixing of Xt/Motif and Qt widgets.
  278.  
  279.   \extension Xt/Motif
  280.  
  281.   The QXtApplication and QXtWidget classes allow old Xt or Motif widgets
  282.   to be used in new Qt applications.  They also allow Qt widgets to
  283.   be used in primarily Xt/Motif applications.  The facility is intended
  284.   to aid migration from Xt/Motif to the more comfortable Qt system.
  285. */
  286.  
  287. static bool my_xt;
  288.  
  289. /*!
  290.   Constructs a QApplication and initializes the Xt toolkit.
  291.   The \a appclass, \a options, \a num_options, and \a resources
  292.   arguments are passed on to XtAppSetFallbackResources and
  293.   XtDisplayInitialize.
  294.  
  295.   Use this constructor when writing a new Qt application which
  296.   needs to use some existing Xt/Motif widgets.
  297.  
  298.   The \a argc and \a argv arguments are passed to the QApplication
  299.   constructor.
  300. */
  301. QXtApplication::QXtApplication(int& argc, char** argv,
  302.     const char* appclass, XrmOptionDescRec *options,
  303.     int num_options,
  304.     const char** resources) :
  305.     QApplication(argc, argv)
  306. {
  307.     my_xt = TRUE;
  308.     XtToolkitInitialize();
  309.     appcon = XtCreateApplicationContext();
  310.     if (resources)
  311.     XtAppSetFallbackResources(appcon, (char**)resources);
  312.     XtDisplayInitialize(appcon, qt_xdisplay(), name(),
  313.     appclass, options, num_options, &argc, argv);
  314.     init();
  315. }
  316.  
  317. /*!
  318.   Constructs a QApplication from the \a display of an already-initialized
  319.   Xt application.  If \a visual and \a colormap are non-zero, the application
  320.   will use those as the default Visual and Colormap contexts.
  321.  
  322.   Use this constructor when introducing Qt widgets into an existing
  323.   Xt/Motif application.
  324. */
  325. QXtApplication::QXtApplication(Display *display, HANDLE visual, HANDLE colormap) :
  326.     QApplication(display, visual, colormap)
  327. {
  328.     my_xt = FALSE;
  329.     init();
  330.     appcon = XtDisplayToApplicationContext(display);
  331. }
  332.  
  333.  
  334. /*!
  335.     \overload
  336.   Constructs a QApplication from the \a display of an already-initialized
  337.   Xt application.  If \a visual and \a colormap are non-zero, the application
  338.   will use those as the default Visual and Colormap contexts.
  339.  
  340.   Use this constructor when introducing Qt widgets into an existing
  341.   Xt/Motif application.
  342.  
  343.   The \a argc and \a argv arguments are passed to the QApplication
  344.   constructor.
  345. */
  346. QXtApplication::QXtApplication(Display *display, int argc, char **argv,
  347.                    HANDLE visual, HANDLE colormap)
  348.     : QApplication(display, argc, argv, visual, colormap)
  349. {
  350.     my_xt = FALSE;
  351.     init();
  352.     appcon = XtDisplayToApplicationContext(display);
  353. }
  354.  
  355.  
  356. /*!
  357.   Destructs the application.  Does not close the Xt toolkit.
  358. */
  359. QXtApplication::~QXtApplication()
  360. {
  361.     Q_ASSERT(qxtapp==this);
  362.     removeXtEventFilters();
  363.     qxtapp = 0;
  364.  
  365.     // the manpage says: "or just exit", that's what we do to avoid
  366.     // double closing of the display
  367. //     if (my_xt) {
  368. //      XtDestroyApplicationContext(appcon);
  369. //      }
  370. }
  371.  
  372. void QXtApplication::init()
  373. {
  374.     Q_ASSERT(qxtapp==0);
  375.     qxtapp = this;
  376.     installXtEventFilters();
  377.     qt_np_add_timeoutcb(np_do_timers);
  378.     qt_np_add_timer_setter(np_set_timer);
  379.     qt_np_add_event_proc(np_event_proc);
  380.     qt_np_count++;
  381. }
  382.  
  383.  
  384. /*!
  385.   \class QXtWidget qxt.h
  386.   \brief The QXtWidget class allows mixing of Xt/Motif and Qt widgets.
  387.  
  388.   \extension Xt/Motif
  389.  
  390.   QXtWidget acts as a bridge between Xt and Qt. For utilizing old
  391.   Xt widgets, it can be a QWidget
  392.   based on a Xt widget class. For including Qt widgets in an existing
  393.   Xt/Motif application, it can be a special Xt widget class that is
  394.   a QWidget.  See the constructors for the different behaviors.
  395. */
  396.  
  397. void QXtWidget::init(const char* name, WidgetClass widget_class,
  398.             Widget parent, QWidget* qparent,
  399.             ArgList args, Cardinal num_args,
  400.             bool managed)
  401. {
  402.     need_reroot=FALSE;
  403.     xtparent = 0;
  404.     if ( parent ) {
  405.     Q_ASSERT(!qparent);
  406.     xtw = XtCreateWidget(name, widget_class, parent, args, num_args);
  407.     if ( widget_class == qWidgetClass )
  408.         ((QWidgetRec*)xtw)->qwidget.qxtwidget = this;
  409.     xtparent = parent;
  410.     if (managed)
  411.         XtManageChild(xtw);
  412.     } else {
  413.     Q_ASSERT(!managed);
  414.  
  415.     String n, c;
  416.     XtGetApplicationNameAndClass(qt_xdisplay(), &n, &c);
  417.     xtw = XtAppCreateShell(n, c, widget_class, qt_xdisplay(),
  418.                    args, num_args);
  419.     if ( widget_class == qWidgetClass )
  420.         ((QWidgetRec*)xtw)->qwidget.qxtwidget = this;
  421.     }
  422.  
  423.     if ( qparent ) {
  424.     XtResizeWidget( xtw, 100, 100, 0 );
  425.     XtSetMappedWhenManaged(xtw, False);
  426.     XtRealizeWidget(xtw);
  427.     XSync(qt_xdisplay(), False);    // I want all windows to be created now
  428.     XReparentWindow(qt_xdisplay(), XtWindow(xtw), qparent->winId(), x(), y());
  429.     XtSetMappedWhenManaged(xtw, True);
  430.     need_reroot=TRUE;
  431.     }
  432.  
  433.     Arg reqargs[20];
  434.     Cardinal nargs=0;
  435.     XtSetArg(reqargs[nargs], XtNx, x());    nargs++;
  436.     XtSetArg(reqargs[nargs], XtNy, y());    nargs++;
  437.     XtSetArg(reqargs[nargs], XtNwidth, width());    nargs++;
  438.     XtSetArg(reqargs[nargs], XtNheight, height());    nargs++;
  439.     //XtSetArg(reqargs[nargs], "mappedWhenManaged", False);    nargs++;
  440.     XtSetValues(xtw, reqargs, nargs);
  441.  
  442.     //#### destroy();   MLK
  443.  
  444.     if (!parent || XtIsRealized(parent))
  445.     XtRealizeWidget(xtw);
  446. }
  447.  
  448. /*!
  449.   Constructs a QXtWidget of the special Xt widget class known as
  450.   "QWidget" to the resource manager.
  451.  
  452.   Use this constructor to utilize Qt widgets in an Xt/Motif
  453.   application.  The QXtWidget is a QWidget, so you can create
  454.   subwidgets, layouts, etc. using Qt functionality.
  455.  
  456.   The \a name is the object name passed to the QWidget constructor.
  457.   The widget's parent is \a parent.
  458.  
  459.   If the \a managed parameter is TRUE and \a parent in not null,
  460.   XtManageChild it used to manage the child.
  461. */
  462. QXtWidget::QXtWidget(const char* name, Widget parent, bool managed)
  463.     : QWidget( 0, name, WResizeNoErase ), xtw( 0 )
  464. {
  465.     init(name, qWidgetClass, parent, 0, 0, 0, managed);
  466.     Arg reqargs[20];
  467.     Cardinal nargs=0;
  468.     XtSetArg(reqargs[nargs], XtNborderWidth, 0);            nargs++;
  469.     XtSetValues(xtw, reqargs, nargs);
  470. }
  471.  
  472. /*!
  473.   Constructs a QXtWidget of the given \a widget_class called \a name.
  474.  
  475.   Use this constructor to utilize Xt or Motif widgets in a Qt
  476.   application.  The QXtWidget looks and behaves
  477.   like the Xt class, but can be used like any QWidget.
  478.  
  479.   Note that Xt requires that the most top level Xt widget is a shell.
  480.   This means, if \a parent is a QXtWidget, the \a widget_class can be
  481.   of any kind. If there isn't a parent or the parent is just a normal
  482.   QWidget, \a widget_class should be something like \c
  483.   topLevelShellWidgetClass.
  484.  
  485.   The arguments, \a args, \a num_args are passed on to XtCreateWidget.
  486.  
  487.   If the \a managed parameter is TRUE and \a parent in not null,
  488.   XtManageChild it used to manage the child.
  489. */
  490. QXtWidget::QXtWidget(const char* name, WidgetClass widget_class,
  491.              QWidget *parent, ArgList args, Cardinal num_args,
  492.              bool managed)
  493.     : QWidget( parent, name, WResizeNoErase ), xtw( 0 )
  494. {
  495.     if ( !parent )
  496.     init(name, widget_class, 0, 0, args, num_args, managed);
  497.     else if ( parent->inherits("QXtWidget") )
  498.     init(name, widget_class, ( (QXtWidget*)parent)->xtw , 0, args, num_args, managed);
  499.     else
  500.     init(name, widget_class, 0, parent, args, num_args, managed);
  501.     create(XtWindow(xtw), FALSE, FALSE);
  502. }
  503.  
  504. /*!
  505.   Destructs the QXtWidget.
  506. */
  507. QXtWidget::~QXtWidget()
  508. {
  509.     // Delete children first, as Xt will destroy their windows
  510.     //
  511.     QObjectList* list = queryList("QWidget", 0, FALSE, FALSE);
  512.     if ( list ) {
  513.     QWidget* c;
  514.         QObjectListIt it( *list );
  515.         while ( (c = (QWidget*)it.current()) ) {
  516.             delete c;
  517.             ++it;
  518.         }
  519.         delete list;
  520.     }
  521.  
  522.     if ( need_reroot ) {
  523.     hide();
  524.     XReparentWindow(qt_xdisplay(), winId(), qApp->desktop()->winId(),
  525.         x(), y());
  526.     }
  527.  
  528.     XtDestroyWidget(xtw);
  529.     destroy( FALSE, FALSE );
  530. }
  531.  
  532. /*!
  533.   \fn Widget QXtWidget::xtWidget() const
  534.  
  535.   Returns the Xt widget equivalent for the Qt widget.
  536. */
  537.  
  538.  
  539.  
  540. /*!
  541.   Reimplemented to produce the Xt effect of getting focus when the
  542.   mouse enters the widget. The event is passed in \a e.
  543.  
  544.     \preliminary
  545. */
  546. bool QXtWidget::x11Event( XEvent * e )
  547. {
  548.     if ( e->type == EnterNotify ) {
  549.     if  ( xtparent )
  550.         setActiveWindow();
  551.     }
  552.     return QWidget::x11Event( e );
  553. }
  554.  
  555.  
  556. /*!
  557.   Implement a degree of focus handling for Xt widgets.
  558. */
  559. void QXtWidget::setActiveWindow()
  560. {
  561.     if  ( xtparent ) {
  562.     if ( !QWidget::isActiveWindow() && isActiveWindow() ) {
  563.         XFocusChangeEvent e;
  564.         e.type = FocusIn;
  565.         e.window = winId();
  566.         e.mode = NotifyNormal;
  567.         e.detail = NotifyInferior;
  568.         XSendEvent( qt_xdisplay(), e.window, TRUE, NoEventMask, (XEvent*)&e );
  569.     }
  570.     } else {
  571.     QWidget::setActiveWindow();
  572.     }
  573. }
  574.  
  575. /*!
  576.   Different from QWidget::isActiveWindow()
  577.  */
  578. bool QXtWidget::isActiveWindow() const
  579. {
  580.     Window win;
  581.     int revert;
  582.     XGetInputFocus( qt_xdisplay(), &win, &revert );
  583.  
  584.     if ( win == None) return FALSE;
  585.  
  586.     QWidget *w = find( (WId)win );
  587.     if ( w ) {
  588.     // We know that window
  589.     return w->topLevelWidget() == topLevelWidget();
  590.     } else {
  591.     // Window still may be a parent (if top-level is foreign window)
  592.     Window root, parent;
  593.     Window cursor = winId();
  594.     Window *ch;
  595.     unsigned int nch;
  596.     while ( XQueryTree(qt_xdisplay(), cursor, &root, &parent, &ch, &nch) ) {
  597.         if (ch) XFree( (char*)ch);
  598.         if ( parent == win ) return TRUE;
  599.         if ( parent == root ) return FALSE;
  600.         cursor = parent;
  601.     }
  602.     return FALSE;
  603.     }
  604. }
  605.  
  606. /*!\reimp
  607.  */
  608. void QXtWidget::moveEvent( QMoveEvent* )
  609. {
  610.     if ( xtparent || !xtw )
  611.     return;
  612.     XConfigureEvent c;
  613.     c.type = ConfigureNotify;
  614.     c.event = winId();
  615.     c.window = winId();
  616.     c.x = geometry().x();
  617.     c.y = geometry().y();
  618.     c.width = width();
  619.     c.height = height();
  620.     c.border_width = 0;
  621.     XSendEvent( qt_xdisplay(), c.event, TRUE, NoEventMask, (XEvent*)&c );
  622.     XtMoveWidget( xtw, x(), y() );
  623. }
  624.  
  625. /*!\reimp
  626.  */
  627. void QXtWidget::resizeEvent( QResizeEvent* )
  628. {
  629.     if ( xtparent || !xtw )
  630.     return;
  631.     XtWidgetGeometry preferred;
  632.     (void ) XtQueryGeometry( xtw, 0, &preferred );
  633.     XConfigureEvent c;
  634.     c.type = ConfigureNotify;
  635.     c.event = winId();
  636.     c.window = winId();
  637.     c.x = geometry().x();
  638.     c.y = geometry().y();
  639.     c.width = width();
  640.     c.height = height();
  641.     c.border_width = 0;
  642.     XSendEvent( qt_xdisplay(), c.event, TRUE, NoEventMask, (XEvent*)&c );
  643.     XtResizeWidget( xtw, width(), height(), preferred.border_width );
  644. }
  645.